package org.example.game.weekly.game410;

import java.util.Arrays;
import java.util.List;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/08/03 20:45
 */
public class Solution001 {

    public static void main(String[] args) {
        System.out.println(new Solution001().finalPositionOfSnake(2, Arrays.asList("RIGHT", "DOWN")));
        System.out.println(new Solution001().finalPositionOfSnake(3, Arrays.asList("DOWN", "RIGHT", "UP")));
        System.out.println(new Solution001().finalPositionOfSnake(2, Arrays.asList("RIGHT", "LEFT")));
    }

    public int finalPositionOfSnake(int n, List<String> commands) {
        int x = 0, y = 0;
        for (int i = 0; i < commands.size(); i++) {
            if("UP".equals(commands.get(i))){
                x--;
            } else if ("RIGHT".equals(commands.get(i))) {
                y++;
            } else if ("DOWN".equals(commands.get(i))) {
                x++;
            } else if ("LEFT".equals(commands.get(i))) {
                y--;
            }
        }
        return (x*n)+y;
    }

}
